package shoppingmall.reception.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import shoppingmall.reception.dto.PageBean;
import shoppingmall.reception.dto.Result;
import shoppingmall.reception.service.CarouselService;

/**
 * 前台 轮播图展示相关controller层
 */
@Slf4j
@RestController
public class CarouselController {

    @Autowired
    private CarouselService carouseService;  //service层实例

    /**
     * 查询轮播图数据
     */
    @GetMapping("/reception/carousel")
    public Result getCarouselData () {
        //输出日志
        log.info("获取前台轮播图数据!");
        //调用service层方法
        PageBean carouselData = carouseService.getCarouselData();
        //对返回的结果判断
        if(carouselData.getTotal() == 0) {
            return Result.success("未查询到轮播图列表数据!");
        }
        return Result.success(carouselData);
    }
}
